<?php require_once 'include/head.php';?>
<!--h_r start-->
    <div class="h_r wd95 mA">
		<ul>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    推荐人：　
                </span>
                <span class="fl">
                    <font class="a"><?php echo $parent_user['username'];?></font>
                    <input class="disB name"id="system_balance" type="hidden"value="<?php echo $parent_user['system_balance'];?>" />
                </span>
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    登录账户：　
                </span>
                <input class="disB name"id="username" type="text"onblur="check_name()" placeholder="" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    密码：　
                </span>
                <input class="disB name" id="password" type="password" placeholder="" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    二级密码：　
                </span>
                <input class="disB name" id="password2" type="password" placeholder="" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    姓名：　
                </span>
                <input class="disB name" id="true_name" type="text" placeholder="" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    费用：　
                </span>
                <input class="disB name" id="price" type="text"readonly="readonly" value="<?php echo $system_config['price'];?>" />
                <input class="disB name" id="system_price" type="hidden"readonly="readonly" value="<?php echo $system_config['price'];?>" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    手机号码：　
                </span>
                <input class="disB name" id="phone" type="tel" placeholder="" />
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    联系地址：　
                </span>
               <select name="province" class="wd20" id="province">
                        <?php 
                                foreach($area_list as $key => $value) {
                                        if($value['areano'] == $area_array[0]) {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
                                        }else {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
                                        }									
                                }

                        ?>
                </select>						 
                <select name="city" class="wd20" id="city">						 
                        <?php 
                                foreach($city_list as $key => $value) {
                                        if($value['areano'] == $area_array[1]) {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
                                        }else {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
                                        }									
                                }

                        ?>
                </select>					 
                <select name="county" class="wd20" id="county">							  
                        <?php 
                                foreach($county_list as $key => $value) {
                                        if($value['areano'] == $area_array[2]) {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'" selected = "selected">'.$value['areaname'].'</option>';
                                        }else {
                                                echo ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
                                        }									
                                }

                        ?>
                </select>
            </li>
            <li class="clearfix">
                <span class="fl wd30 texR">
                    详细地址：　
                </span>
                <input class="disB name" style="width:63%;" type="text" id="address" placeholder="" />
                <input style="margin-left:18%;" onclick="post_data()" type="button" class="fl cfff btn" value="确 定" />
                <input style="margin-right:18%;" type="button" onClick="javascript:history.go(-1);" class="fr cfff btn1" value="取 消">
            </li>
        </ul>
    </div>
<!--h_r end-->
</body>
<script src="/public_source/wap/js/areas.js"></script>
<script type="text/javascript">
    function check_name(){
            var username = document.getElementById("username").value;
            
            var data={username:username};
            if(username == null || username==''){
               
                 return false;
            }else{
                var bool=true;
                $.ajax({
			url:"/wap/home/check_name",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}	
		});
                if(!bool) {
		   	$.alert({
			    title: '提示',
			    content:'用户已存在',
			    confirm: function(){
			    }
			});
			return false;	
		}
            }
            return true;
        }
    function post_data(){
       
        var username=$("#username").val();
        if(username==null || username==''){
            $.alert({
                title: '提示',
                content:'登录账户不能为空',
                confirm: function(){
                }
            });
             return false;	
        }
        var check_return=check_name();
        if(check_return){
             var true_name=$("#true_name").val();
        var phone=$("#phone").val();
        var password=$("#password").val();
        var password2=$("#password2").val();
        
        if(password==null || password==''){
            $.alert({
                title: '提示',
                content:'登录密码不能为空',
                confirm: function(){
                }
            });
             return false;	
        }
        if(password2==null || password2==''){
            $.alert({
                title: '提示',
                content:'二级密码不能为空',
                confirm: function(){
                }
            });
             return false;	
        }
        var price=$("#price").val();
        price=parseFloat(price);
        if(isNaN(price)){
               price=0;
           }
            var system_balance = document.getElementById("system_balance").value;
            var system_price = document.getElementById("system_price").value;
           if(system_balance < system_price){
                $.alert({
                 title: '提示',
                 content:'报单币不足',
                 confirm: function(){
                 }
             });
              return false;
           }
        if(price < 0 || price==0){
            $.alert({
                title: '提示',
                content:'价格必须大于0',
                confirm: function(){
                }
            });
             return false;	
        }
        var province=$("#province").val();
        var city=$("#city").val();
        var county=$("#county").val();
        var address=$("#address").val();
        var bank_name=$("#bank_name").val();
        var bank_account=$("#bank_account").val();
        var data={price:price,username:username,true_name:true_name,phone:phone,password:password,password2:password2,province:province,city:city,county:county,address:address,bank_name:bank_name,bank_account:bank_account};
         $.ajax({
                url:"/wap/home/add",
                async: false,
                type:"post",
                data: data,
                dataType: 'json',
                success:function(data) {
                        if(data.success){
                            window.location.href='/wap/home/next_users';
                        }else{
                             $.alert({
                                title: '提示',
                                content:data.msg,
                                confirm: function(){
                                }
                            });
                        }
                }	
        });
        }
       
    }

</script>
</html>